﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using OpenWaves.Web;

[assembly: PublicAssemblyResources("OpenWaves.EPiServer.AdminTools.LogViewer.UI.LogFileListing.aspx")]

namespace OpenWaves.EPiServer.AdminTools.LogViewer.UI
{
    public partial class LogFileListing : AdminPageBase
    {
        public const string PathQueryStringParameter = "path";

        public IEnumerable<LogDirectory> Directories { get; private set; }

        protected override void OnLoad(EventArgs e)
        {            
            Directories = LogViewerPlugin.GetLogDirectories();

            this.DataBind();
        }

        protected static Url GetViewUrl(LogFile logFile)
        {
            UrlBuilder builder = AssemblyResourceVirtualPathProvider.CreateUrl(typeof(FileContentPage)).GetBuilder();
            builder.Query.Add(PathQueryStringParameter, logFile.Path);
            return builder.ToUrl();
        }

        protected static Url GetDownloadUrl(LogFile logFile)
        {
            UrlBuilder builder = AssemblyResourceVirtualPathProvider.CreateUrl(typeof(LogFileDownload)).GetBuilder();
            builder.Query.Add(PathQueryStringParameter, logFile.Path);
            return builder.ToUrl();
        }


        protected static string TranslateFallback(string key, string fallback)
        {
            return LogViewerPlugin.TranslateConfigurationFallback(key, fallback);
        }


    }
}